package com.zkingsoft.actions.admin;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zkingsoft.actions.common.BaseController;
import com.zkingsoft.anotations.RemoveRequestToken;
import com.zkingsoft.anotations.SaveRequestToken;
import com.zkingsoft.model.AdvertisementColumn;
import com.zkingsoft.plugin.pojo.PaginationVO;
import com.zkingsoft.plugin.util.WebUtil;
import com.zkingsoft.pojo.AjaxResult;
import com.zkingsoft.services.AdvertisementColumnService;

/**
 * @author dingchuan
 * @date 2016-07-15 11:19
 * 广告栏Controller
 */
@Controller
@RequestMapping(value = "admin/advertisementColumn")
public class AdvertisementColumnController extends BaseController{

	@Resource
	private AdvertisementColumnService currentService;
	
	/**
	 * 列表显示
	 */
	@RequestMapping(value = "/showList")
	public @ResponseBody AjaxResult showList(AdvertisementColumn advertisementColumn, PaginationVO pageVo) {
		return showList(currentService, advertisementColumn, pageVo);
	}
   	
	/**
	 * 新增或者修改页面
	 */   	
   	@RequestMapping(value = "/addOrModify")
   	@RemoveRequestToken
	public @ResponseBody AjaxResult addOrModify(AdvertisementColumn advertisementColumn) {
		if (advertisementColumn.getId() != null) {
			return modify(currentService, advertisementColumn, "广告栏");
		} else {
			return add(currentService, advertisementColumn, "广告栏");
		}
	}
	
   	/**
	 * 进入修改界面
	 */   
   	@RequestMapping(value = "/editForm")
   	@SaveRequestToken
	public String editForm(Long id) {
		AdvertisementColumn advertisementColumn;
		if (id != null) {
			advertisementColumn = currentService.findById(id);
			WebUtil.getRequest().setAttribute("obj", advertisementColumn);
		}
		return "admin/adColumnManage-form";
	}
   	
   	
   	/**
	 * 删除
	 */  
 	@RequestMapping(value = "/del")
	public @ResponseBody AjaxResult del(String keys) {
		return remove(currentService, keys);
	}
 	

	/**
	 * =======================================================
	 * *******************公共的数据访问方法********************
	 * =======================================================
	 */
	
 	@RequestMapping(value = "/all")
	public @ResponseBody AjaxResult all(AdvertisementColumn advertisementColumn) {
 		List<AdvertisementColumn> list=currentService.findInPage(advertisementColumn, null);
 		return new AjaxResult(AjaxResult.STATUS_OK, null, null, list, null);
	}
}